<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/style_user.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <title>重置密码</title>
</head>
<body>
<form action="" method="post" id="form" >
<div class="wrap-pass">
    <div class="header">
        <p>重置密码</p>
        <img src="__STATIC__/img_user/back.png" class="back" onclick =window.location.href="{:url('mobile/user_port/findPwd')}";>
    </div>
    <div class="center">
        <div>
            <input type="hidden" name="username" value="{$username}"  />
            <input class="text pwd" type="password" name="password" placeholder="密码" dataType="s6-18" nullmsg="请填写密码" errormsg="密码范围在6~18位字符之间!">
            <img src="__STATIC__/img_user/dl-mimab.png" class="showPwd" id="p" onclick="toggle()">
        </div>
        <div>
            <input class="text pwd" type="password" name="confirmPassword"  dataType="*" recheck="password" errormsg="两次密码不一致" placeholder="确认密码" nullmsg="请确认密码" >
        </div>
    </div>
    <input type="submit" class="submit" id="sub" value="确定">
</div>
</form>
{include file="public/src" /}
<script>
    //切换密码的可视类型
    function toggle(){
        var type = $(".pwd");
        type.each(function (i,o) {
            if ($(o).prop('type') == 'text'){
                $(o).prop('type','password');
                $('#p').prop('src','__STATIC__/img_user/dl-mimab.png');
            }else if ($(o).prop('type') == 'password'){
                $(o).prop('type','text');
                $('#p').prop('src','__STATIC__/img_user/dl-mima.png');
            }
        })
    }
    //验证表单元素
    $(function () {
        $.Tipmsg.r = null;
        $.Tipmsg.p = null;
        var demo = $("#form").Validform({
            tiptype: function (msg) {
                layer.open({content: msg, skin: 'msg', time:2});
            },
            btnSubmit:'#sub',
            tipSweep: true,
            ajaxPost:true,
            callback:function(t){
                console.log(t);
                if (t.code == 200){
                    layer.open({content:t.message,skin:'msg',time:2});
                    setTimeout(function () {
                      window.location.href = "login";
                    },2000)
                }else{
                    layer.open({content:t.message,skin:'msg',time:2});
                }
            }
        });
        demo.config({
            ajaxpost:{
                error: function () {
                    layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                }
            }
        })
    });
</script>
</body>
</html>